package com.qf.shopback.controller;

import com.baomidou.mybatisplus.plugins.Page;
import com.qf.common.result.ResultEntity;
import com.qf.entity.User;
import com.qf.feign.UserFeignService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
@RequestMapping("/user")
public class UserController {
    @Autowired
    private UserFeignService userFeignService;

    @RequestMapping("getUser")
    public String getPage(Page<User> page, ModelMap modelMap) {
        //获取数据，需要feign来调用
        page = userFeignService.getUserPage(page);

        //存入作用域
        modelMap.put("page", page);
        return "user/userList";
    }

    @RequestMapping("/addUser")
    @ResponseBody
    public ResultEntity addUser(User user) {
//        System.out.println(user);
//        return ResultEntity.success();
       return userFeignService.addUser(user);
    }
}
